package com.masblearn;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class ColiderChain implements Colider {
    private List<Colider> coliders = new LinkedList<>();

    public ColiderChain() {
        add(new BulletTankColider());
        add(new TankTankColider());
        add(new BulletWallColider());
        add(new TankWallColider());
    }

    public void add(Colider colider) {
        coliders.add(colider);
    }

    @Override
    public boolean colider(GameObject o1, GameObject o2) {
        for (int i = 0; i < coliders.size(); i++) {
           if(!coliders.get(i).colider(o1,o2)){
               return false;
           }
        }
        return true;
    }
}
